<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <h1>微博首页</h1>

        <a href="/reg.html">注册</a>
        <a href="/login.html">登录</a>
    <hr>
    <a href="javascript:void(0)" @click="test()">权限测试</a>
    <a href="javascript:void(0)" @click="current()">获取登录用户</a>
    <a href="javascript:void(0)" @click="logout()">退出登录</a>

</div>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
        },
        methods:{
            test(){
                axios.get("/permission").then(function (response) {
                    if(response.data.code==20000){
                        alert("当前登录的是管理员 访问通过！");
                    }else{
                        alert(response.data.msg);
                    }
                })
            },
            current(){
                axios.get("/current").then(function (response) {
                    //得到当前登录的用户信息
                    alert(response.data.data.nickname);
                })
            }, logout(){
                axios.get("/logout").then(function (response) {
                    alert("退出登录!")
                    location.reload();
                })
            }
        },
    })
</script>
</body>
</html>